// Created: 08/27/2025, ChangJiang Ru
public class USBTest
{
    public static void main(String[] args)
    {
        // Case 1 : Using polymorphic of interface
        Computer computer = new Computer();
        USB printer = new Printer();
        computer.transferData(printer);
        System.out.println();

        // Case 2: Using anonymity object
        computer.transferData(new Camera());
        System.out.println();

        // Case 3: Using interface object
        computer.transferData(new USB(){
            @Override
            public void start()
            {
                System.out.println("Scanner start to work!");
            }

            @Override
            public void stop()
            {
                System.out.println("Scanner stop to work!");
            }
        });
        System.out.println();

        // Case 4: Using anonymity implement class of anonymity object
        USB usb = new USB(){
            @Override
            public void start()
            {
                System.out.println("C disk start to work!");
            }

            @Override
            public void stop()
            {
                System.out.println("C disk stop to work!");
            }
        };
        computer.transferData(usb);

    }
}

class Computer
{
    public void transferData(USB usb)
    {
      System.out.println("The device connected is successful!");
      usb.start();
      System.out.println("The data are transferring!");
      usb.stop();
    }
}

class Printer implements USB
{
    @Override
    public void start()
    {
        System.out.println("Printer start to work!");
    }

    @Override
    public void stop()
    {
        System.out.println("Printer stop to work!");
    }
}

class Camera implements USB
{
    @Override
    public void start()
    {
        System.out.println("Camera start to work!");
    }

    @Override
    public void stop()
    {
        System.out.println("Camera stop to work!");
    }
}
interface USB
{
    // Instant files

    // Start and stop method
    public abstract void start();
    public abstract void stop();
}


